// pages/read/index.js
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    testName: '',
    score: '',
    doTime: '',
    tempQuestionArrays:{},
    doTime: 0,
    employeeName: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var paperId = options.id
    var testName = options.testname
    var testLength = options.testlength
    var excamMark = options.excammark
    var empinfo = wx.getStorageSync('empinfo')
    //('人员姓名'+empinfo.employeeName)
    var that  = this
    that.setData({
      spinShow: true,
      testName: testName,
      score: excamMark,
      doTime: testLength,
      employeeName: empinfo.employeeName
    });
    
    app.formPost('/wx/test/get-transcript-read',{
      excamTranscriptInfoId: paperId,
    }).then(res=>{
      that.setData({
        spinShow: false
      });
      wx.stopPullDownRefresh()
        if(res.code == 200){
          //console.log(res.transcriptInfoReads.length)
          //console.log(res.transcriptInfoReads)
          var questionInfos = res.transcriptInfoReads;
          if(questionInfos.length > 0){
            for(var i = 0; i < questionInfos.length; i++ ){
              var jsOptions = JSON.parse(questionInfos[i].options);
              questionInfos[i]['options1'] = jsOptions;
            }
          }
          that.setData({
            tempQuestionArrays: questionInfos
          });
      }
    }).catch(e => {
      that.setData({
        spinShow: false
      });
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})